package com.ymatou.iapi.dglogin.testcase;

import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.common.lang.CipherUtil;
import com.ymatou.iapi.dglogin.parameter.AppSourceEnum;
import com.ymatou.iapi.dglogin.parameter.SellerRegisterBean;
import com.ymatou.iapi.dglogin.parameter.WxLoginSession;
import com.ymatou.iapi.dglogin.service.SellerRegisterCall;
import com.ymatou.iapi.dguser.parameter.UserCreateBean;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.DGUserCallService;
import com.ymttest.database.model.DGThirdPartyBindInfo;
import com.ymttest.database.model.DGUserExtInfo;
import com.ymttest.database.model.DGUserInfo;
import com.ymttest.database.model.DGWxUnionidBindInfo;
import com.ymttest.database.mongo.UserTokenWapper;
import com.ymttest.database.sqlwapper.DGUserWapper;
import com.ymttest.utils.TestDataManager;
/**
*商家注册并且联登
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SellerRegister{
	private static SellerRegisterBean sellerregisterBean;
	private static SellerRegisterCall sellerregisterCall;
	DGUserWapper DGUserWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("商家注册并且联登");
	}

	@Before
	public void caseUp() {
		sellerregisterBean=new SellerRegisterBean();
		sellerregisterCall=new SellerRegisterCall();
		DGUserWapper=new DGUserWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(sellerregisterCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private String getLoginSession(UserCreateBean u) throws Exception {
		WxLoginSession wxLoginSession=new WxLoginSession();
		wxLoginSession.setOpenId(u.getOpenId());
		wxLoginSession.setSessionKey(TestDataManager.getUTF8Base64(DGUserCallService.SESSIONKEY));
		wxLoginSession.setUnionId(u.getUnionId());
		String loginSession = DGUserCallService.encryptWxLoginSession(wxLoginSession);
		return loginSession;
	}
	private SellerRegisterBean initSellerRegBean(UserCreateBean u) throws Exception {
		SellerRegisterBean srb=new SellerRegisterBean();
		srb.setAppSource(u.getAppSource());
		srb.setClientIp(u.getClientIp());
		srb.setCountryCode(u.getCountryCode());
		srb.setInvitationCode(u.getInvitationCode());
		srb.setLoginSession(getLoginSession(u));
		srb.setLogoUrl(u.getLogoUrl());
		srb.setMobile(u.getMobile());
		srb.setMobileAreaCode(u.getMobileAreaCode());
		srb.setNickname(u.getNickname());
		srb.setTerminalSource(u.getTerminalSource());
		srb.setUserGender(u.getUserGender());
		srb.setWxAppName(u.getWxAppName());
		return srb;
	}
	private void verifyDB(UserCreateBean usercreateBean2, Integer uid) {
		Logger.comment("验证DGUserInfo");
		DGUserInfo uinfo = DGUserWapper.selectDGUserInfo(uid).get(0);
		Logger.verifyEquals(usercreateBean2.getIscs() == null ? false : usercreateBean2.getIscs(), uinfo.getIsCs(), "验证IsCs");
		//loginid随机生成
		Logger.verifyNotNull(uinfo.getLoginId(), "验证LoginId");
		Logger.verifyNotNull(uinfo.getLoginPwd(), "验证LoginPwd");
		Logger.verifyEquals(usercreateBean2.getLogoUrl(), uinfo.getLogoUrl(), "验证LogoUrl");
		if (usercreateBean2.getMobile() != null) {
			Logger.verifyEquals(usercreateBean2.getMobile(), uinfo.getMobile(), "验证Mobile");
		}
		if (usercreateBean2.getMobileAreaCode() != null) {
			Logger.verifyEquals(usercreateBean2.getMobileAreaCode(), uinfo.getMobileAreaCode(), "验证MobileAreaCode");
		}
		if (usercreateBean2.getBelongSellerId() != null) {
			Logger.verifyEquals(usercreateBean2.getBelongSellerId(), uinfo.getBelongSellerId(), "验证BelongSellerId");
		}
		boolean haspwd=false;
		if(sellerregisterBean.getPassword()!=null&&sellerregisterBean.getPassword().length()>0) {
			haspwd=true;
		}
		Logger.verifyEquals(haspwd, uinfo.getIsSetPwd(), "验证IsSetPwd");
		Logger.verifyEquals(usercreateBean2.getNickname(), uinfo.getNickname(), "验证Nickname");
		Logger.verifyEquals(usercreateBean2.getUserGender()==null?0:usercreateBean2.getUserGender(), uinfo.getUserGender(), "验证UserGender");
		Logger.verifyEquals(usercreateBean2.getUserType()==null?0:usercreateBean2.getUserType(), uinfo.getUserType(), "验证UserType");
		Logger.verifyEquals(0, uinfo.getUserStatus(), "验证UserStatus");
		Logger.comment("验证DGUserExtInfo");
		DGUserExtInfo exinfo = DGUserWapper.selectDGUserExtInfo(uid).get(0);
		Logger.verifyEquals(usercreateBean2.getAppSource(), exinfo.getAppSource(), "验证AppSource");
		Logger.verifyEquals(usercreateBean2.getChannelSource()==null?0:usercreateBean2.getChannelSource(), exinfo.getChannelSource(), "验证ChannelSource");
		if (usercreateBean2.getClientIp() != null) {
			Logger.verifyEquals(usercreateBean2.getClientIp(), exinfo.getClientIp(), "验证ClientIp");
		}
		Logger.verifyEquals(usercreateBean2.getCountryCode(), exinfo.getCountryCode(), "验证CountryCode");
		//根据uid和oid生成设备号
		if(usercreateBean2.getOpenId()!=null&&usercreateBean2.getUnionId()!=null) {
			Logger.verifyEquals(CipherUtil.encryptMD5(usercreateBean2.getUnionId()), exinfo.getPhysicsDeviceId(), "验证DeviceId");
			Logger.verifyEquals(CipherUtil.encryptMD5(usercreateBean2.getOpenId()), exinfo.getLogicDeviceId(), "验证EquipmentId");
		}
		if (usercreateBean2.getInvitationCode() != null) {
			Logger.verifyEquals(usercreateBean2.getInvitationCode(), exinfo.getInvitationCode(), "验证InvitationCode");
		}
		//现在没有remark
//		if (usercreateBean2.getRemark() != null) {
//			Logger.verifyEquals(usercreateBean2.getRemark(), exinfo.getRemark(), "验证Remark");
//		}
		Logger.verifyEquals(usercreateBean2.getTerminalSource()==null?0:usercreateBean2.getTerminalSource(), exinfo.getTerminalSource(), "验证TerminalSource");
		if(usercreateBean2.getOpenId()!=null&&usercreateBean2.getUnionId()!=null) {
		Logger.comment("验证DGThirdPartyBindInfo");
		DGThirdPartyBindInfo tpinfo = DGUserWapper.selectDGThirdPartyBindInfo(uid).get(0);
		// 多绑定关系在login站点考虑 这里主要看数据落地正确
		Logger.verifyEquals(usercreateBean2.getAppSource(), tpinfo.getAppSource(), "验证AppSource");
		Logger.verifyEquals(usercreateBean2.getOpenId(), tpinfo.getOpenId(), "验证OpenId");
		Logger.verifyEquals(usercreateBean2.getChannelSource()==null?0:usercreateBean2.getChannelSource(), tpinfo.getThirdPartyType(), "验证ThirdPartyType");
		if (usercreateBean2.getUnionId() != null) {
			Logger.verifyEquals(usercreateBean2.getUnionId(), tpinfo.getUnionId(), "验证UnionId");
		}
		Logger.verifyEquals(usercreateBean2.getUserType()==null?0:usercreateBean2.getUserType(), tpinfo.getUserType(), "验证UserType");

		Logger.comment("验证DGWxUnionidBindInfo");
		List<DGWxUnionidBindInfo> wxuinfo = DGUserWapper.selectDGWxUnionidBindInfo(uid);
		if (wxuinfo.size() > 0) {
			Logger.verifyEquals(usercreateBean2.getUserType()==null?0:usercreateBean2.getUserType(), wxuinfo.get(0).getUserType(), "验证UserType");
			Logger.verifyEquals(usercreateBean2.getUnionId(), wxuinfo.get(0).getUnionId(), "验证UnionId");
		}
		}else {
			List<DGThirdPartyBindInfo> tpinfo = DGUserWapper.selectDGThirdPartyBindInfo(uid);
			List<DGWxUnionidBindInfo> wxuinfo = DGUserWapper.selectDGWxUnionidBindInfo(uid);
			Logger.verifyEquals(0, tpinfo.size(), "没有微信绑定信息");
			Logger.verifyEquals(0, wxuinfo.size(), "没有微信绑定信息");
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SellerRegister_001() {
		Logger.start(true,"商家注册并且联登,成功");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setInvitationCode("test");
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();			
			Logger.verifyEquals("true", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyNotNull(sellerregisterCall.getString("userId"), "验证uid");
			verifyDB(u, Integer.valueOf(sellerregisterCall.getString("userId")));
			Map<String, Object> token = new UserTokenWapper().getUserTokenByUid(Integer.valueOf(sellerregisterCall.getString("userId")));
			Logger.comment(token.toString());
			Logger.verifyEquals(AppSourceEnum.parse(u.getAppSource()).toString().toLowerCase(), token.get("tSource"), "验证tSource");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	

	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_002() {
		Logger.start(true,"手机已注册商家微信授权联登,失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			u.setOpenId(u.getOpenId()+1);
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("101", sellerregisterCall.getString("errorCode"), "验证errorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_003() {
		Logger.start(true,"微信已注册商家微信授权联登openid重复,失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			u.setMobile(TestDataManager.getPhoneNum());
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("2", sellerregisterCall.getString("errorCode"), "验证errorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_004() {
		Logger.start(true,"不输入loginSession失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setLoginSession(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("1", sellerregisterCall.getString("errorCode"), "验证errorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_005() {
		Logger.start(true,"不输入nickname失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setNickname(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("1", sellerregisterCall.getString("errorCode"), "验证errorCode");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	//http://jira.ymatou.cn:8080/browse/JIRACONN-30345
	public void Tc_SellerRegister_006() {
		Logger.start(true,"不输入logoUrl失败->成功");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setLogoUrl(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("true", sellerregisterCall.getString("success"), "验证success");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_007() {
		Logger.start(true,"不输入wxAppName失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setWxAppName(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("1", sellerregisterCall.getString("errorCode"), "验证errorCode");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_008() {
		Logger.start(false,"不输入userGender失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			//为空时默认0 未知
			u.setUserGender(0);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setUserGender(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("1", sellerregisterCall.getString("errorCode"), "验证errorCode");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_009() {
		Logger.start(true,"不输入mobile失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setMobile(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("1", sellerregisterCall.getString("errorCode"), "验证errorCode");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_010() {
		Logger.start(true,"不输入mobileAreaCode失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setMobileAreaCode(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("1", sellerregisterCall.getString("errorCode"), "验证errorCode");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_011() {
		Logger.start(true,"不输入CountryCode失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setCountryCode(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("1", sellerregisterCall.getString("errorCode"), "验证errorCode");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_012() {
		Logger.start(true,"不输入InvitationCode成功");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setInvitationCode(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("true", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyNotNull(sellerregisterCall.getString("userId"), "验证uid");
			verifyDB(u, Integer.valueOf(sellerregisterCall.getString("userId")));
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_013() {
		Logger.start(true,"不输入appSource失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			
			sellerregisterBean.setAppSource(null);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("1", sellerregisterCall.getString("errorCode"), "验证errorCode");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_014() {
		Logger.start(true,"客服已经注册过了失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setIscs(true);
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			//注册客服
			Integer sellerid=DGUserCallService.UserCreateCall(u);
			//客服不需要手机号区号，注册成功后再填入
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();			
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("2", sellerregisterCall.getString("errorCode"), "验证errorCode");	
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SellerRegister_015() {
		Logger.start(true,"普通用户已经注册过了unionid相同,注册成功");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			Integer uid=DGUserCallService.UserCreateCall(u);
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerWxApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();			
			Logger.verifyEquals("true", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyNotNull(sellerregisterCall.getString("userId"), "验证uid");
			verifyDB(u, Integer.valueOf(sellerregisterCall.getString("userId")));
			Logger.verifyNotEquals(uid,  Integer.valueOf(sellerregisterCall.getString("userId")), "创建了2个用户");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SellerRegister_016() {
		Logger.start(true,"商家注册并且联登,成功-手机注册没有微信信息");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setInvitationCode("test");
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			u.setOpenId(null);
			u.setUnionId(null);
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();			
			Logger.verifyEquals("true", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyNotNull(sellerregisterCall.getString("userId"), "验证uid");
			verifyDB(u, Integer.valueOf(sellerregisterCall.getString("userId")));
			Map<String, Object> token = new UserTokenWapper().getUserTokenByUid(Integer.valueOf(sellerregisterCall.getString("userId")));
			Logger.comment(token.toString());
			Logger.verifyEquals(AppSourceEnum.parse(u.getAppSource()).toString().toLowerCase(), token.get("tSource"), "验证tSource");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SellerRegister_0017() {
		Logger.start(true,"商家注册并且联登,成功-有密码");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setInvitationCode("test");
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterBean.setPassword("123456a");
			sellerregisterBean.setRegisterMode(1);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();			
			Logger.verifyEquals("true", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyNotNull(sellerregisterCall.getString("userId"), "验证uid");
			verifyDB(u, Integer.valueOf(sellerregisterCall.getString("userId")));
			Map<String, Object> token = new UserTokenWapper().getUserTokenByUid(Integer.valueOf(sellerregisterCall.getString("userId")));
			Logger.comment(token.toString());
			Logger.verifyEquals(AppSourceEnum.parse(u.getAppSource()).toString().toLowerCase(), token.get("tSource"), "验证tSource");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SellerRegister_018() {
		Logger.start(true,"商家注册并且联登,商家手机号码已经被注册了失败");
		try {
			UserCreateBean u= DGUserCallService.initUsercreateBean();
			u.setInvitationCode("test");
			u.setMobile(TestDataManager.getPhoneNum());
			u.setMobileAreaCode("86");
			u.setUserType(1);
			u.setAppSource(DGUserCallService.DG_SellerApp);
			u.setWxAppName(DGUserCallService.TestWxsqSeller);
			sellerregisterBean=initSellerRegBean(u);
			sellerregisterCall.setData(sellerregisterBean);
			sellerregisterCall.callService();		
			sellerregisterCall.callService();		
			Logger.verifyEquals("false", sellerregisterCall.getString("success"), "验证success");
			Logger.verifyEquals("101", sellerregisterCall.getString("errorCode"), "验证errorCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}